/**
 * @note 预警信息查询页面初始化加载
 * @author 李峰
 * @create_time 2017-09-22
 */
 
 
var Global = {
	common: {
		ajaxPath: (window.location + "").split("/")[0] + "//" + (window.location + "").split("/")[2] + "/" + (window.location + "").split("/")[3]
	},
	//预警信息图标
	monitor: {
		yjxh: [
			{flag:"yj_12_2",name:"大雾",level:"黄色"},
			{flag:"yj_12_3",name:"大雾",level:"橙色"},
			{flag:"yj_12_4",name:"大雾",level:"红色"},
			{flag:"yj_13_2",name:"霾",level:"黄色"},
			{flag:"yj_13_3",name:"霾",level:"橙色"},
			{flag:"yj_14_2",name:"道路结冰",level:"黄色"},
			{flag:"yj_14_3",name:"道路结冰",level:"橙色"},
			{flag:"yj_14_4",name:"道路结冰",level:"红色"},
			{flag:"yj_1_2",name:"台风",level:"黄色"},
			{flag:"yj_1_3",name:"台风",level:"橙色"},
			{flag:"yj_1_4",name:"台风",level:"红色"},
			{flag:"yj_6_3",name:"沙尘暴",level:"橙色"},
			{flag:"yj_6_4",name:"沙尘暴",level:"红色"},
			{flag:"yj_7_2",name:"高温",level:"黄色"},
			{flag:"yj_7_3",name:"高温",level:"橙色"},
			{flag:"yj_7_4",name:"高温",level:"红色"},
			{flag:"yj_8_3",name:"干旱",level:"橙色"},
			{flag:"yj_8_4",name:"干旱",level:"红色"},
			{flag:"yj_9_2",name:"雷电",level:"黄色"},
			{flag:"yj_9_3",name:"雷电",level:"橙色"},
			{flag:"yj_9_4",name:"雷电",level:"红色"},
			{flag:"yj_10_3",name:"冰雹",level:"橙色"},
			{flag:"yj_10_4",name:"冰雹",level:"红色"},
			{flag:"yj_11_1",name:"霜冻",level:"蓝色"},
			{flag:"yj_11_2",name:"霜冻",level:"黄色"},
			{flag:"yj_11_3",name:"霜冻",level:"橙色"},
			{flag:"yj_15_2",name:"森林火险",level:"黄色"},
			{flag:"yj_15_3",name:"森林火险",level:"橙色"},
			{flag:"yj_15_4",name:"森林火险",level:"红色"},
			{flag:"yj_2_1",name:"暴雨",level:"蓝色"},
			{flag:"yj_2_2",name:"暴雨",level:"黄色"},
			{flag:"yj_2_3",name:"暴雨",level:"橙色"},
			{flag:"yj_2_4",name:"暴雨",level:"红色"},
			{flag:"yj_3_1",name:"暴雪",level:"蓝色"},
			{flag:"yj_3_2",name:"暴雪",level:"黄色"},
			{flag:"yj_3_3",name:"暴雪",level:"橙色"},
			{flag:"yj_3_4",name:"暴雪",level:"红色"},
			{flag:"yj_4_1",name:"寒潮",level:"蓝色"},
			{flag:"yj_4_2",name:"寒潮",level:"黄色"},
			{flag:"yj_4_3",name:"寒潮",level:"橙色"},
			{flag:"yj_4_4",name:"寒潮",level:"红色"},
			{flag:"yj_1_1",name:"台风",level:"蓝色"},
			{flag:"yj_5_1",name:"大风",level:"蓝色"},
			{flag:"yj_5_2",name:"大风",level:"黄色"},
			{flag:"yj_5_3",name:"大风",level:"橙色"},
			{flag:"yj_5_4",name:"大风",level:"红色"},
			{flag:"yj_6_2",name:"沙尘暴",level:"黄色"}
		],
		jcbj: [
			{flag:"HighTempMonitor",name:"高温",status:1},
			{flag:"LowTempMonitor",name:"低温",status:1},
			{flag:"2MinAvgWinMonitor",name:"2分钟平均风速",status:1},
			{flag:"10MinAvgWinMonitor",name:"10分钟平均风速",status:1},
			{flag:"1HourPreMonitor",name:"过去1小时降水量",status:1},
			{flag:"3HourPreMonitor",name:"过去3小时降水量",status:1}
		],
		color: [
			{name:"蓝色",value:"#0000FF"},
			{name:"黄色",value:"#FFFF00"},
			{name:"橙色",value:"#FFA500"},
			{name:"红色",value:"#FF0000"},
			{name:"绿色",value:"#00FF00"}
		],
		imgUrl: [
			{name:"BlueHighTempMonitor",value:"resources/images/indexMap/BlueHighTempMonitor.gif",rotation:false,width:30,height:30},
			{name:"OrangeHighTempMonitor",value:"resources/images/indexMap/OrangeHighTempMonitor.gif",rotation:false,width:30,height:30},
			{name:"RedHighTempMonitor",value:"resources/images/indexMap/RedHighTempMonitor.gif",rotation:false,width:30,height:30},
			{name:"BlueLowTempMonitor",value:"resources/images/indexMap/BlueLowTempMonitor.gif",rotation:false,width:30,height:30},
			{name:"OrangeLowTempMonitor",value:"resources/images/indexMap/OrangeLowTempMonitor.gif",rotation:false,width:30,height:30},
			{name:"RedLowTempMonitor",value:"resources/images/indexMap/RedLowTempMonitor.gif",rotation:false,width:30,height:30},
			{name:"2MinAvgBuleWinMonitor",value:"resources/images/indexMap/BlueWinMonitor.png",rotation:true,width:20,height:20},
			{name:"2MinAvgOrangeWinMonitor",value:"resources/images/indexMap/OrangeWinMonitor.png",rotation:true,width:20,height:20},
			{name:"2MinAvgRedWinMonitor",value:"resources/images/indexMap/RedWinMonitor.png",rotation:true,width:20,height:20},
			{name:"10MinAvgBuleWinMonitor",value:"resources/images/indexMap/BlueWinMonitor.png",rotation:true,width:20,height:20},
			{name:"10MinAvgOrangeWinMonitor",value:"resources/images/indexMap/OrangeWinMonitor.png",rotation:true,width:20,height:20},
			{name:"10MinAvgRedWinMonitor",value:"resources/images/indexMap/RedWinMonitor.png",rotation:true,width:20,height:20},
			{name:"1HourBulePreMonitor",value:"resources/images/indexMap/BluePreMonitor.gif",rotation:false,width:20,height:20},
			{name:"1HourOrangePreMonitor",value:"resources/images/indexMap/OrangePreMonitor.gif",rotation:false,width:20,height:20},
			{name:"1HourRedPreMonitor",value:"resources/images/indexMap/RedPreMonitor.gif",rotation:false,width:20,height:20},
			{name:"3HourBulePreMonitor",value:"resources/images/indexMap/BluePreMonitor.gif",rotation:false,width:20,height:20},
			{name:"3HourOrangePreMonitor",value:"resources/images/indexMap/OrangePreMonitor.gif",rotation:false,width:20,height:20},
			{name:"3HourRedPreMonitor",value:"resources/images/indexMap/RedPreMonitor.gif",rotation:false,width:20,height:20},
			{name:"yj_12_2",value:"resources/images/indexMap/heavyfog_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_12_3",value:"resources/images/indexMap/heavyfog_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_12_4",value:"resources/images/indexMap/heavyfog_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_13_2",value:"resources/images/indexMap/haze_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_13_3",value:"resources/images/indexMap/haze_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_14_2",value:"resources/images/indexMap/roadicing_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_14_3",value:"resources/images/indexMap/roadicing_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_14_4",value:"resources/images/indexMap/roadicing_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_1_2",value:"resources/images/indexMap/typhoon_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_1_3",value:"resources/images/indexMap/typhoon_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_1_4",value:"resources/images/indexMap/typhoon_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_6_3",value:"resources/images/indexMap/shachengbao_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_6_4",value:"resources/images/indexMap/shachengbao_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_7_2",value:"resources/images/indexMap/heatwave_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_7_3",value:"resources/images/indexMap/heatwave_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_7_4",value:"resources/images/indexMap/heatwave_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_8_3",value:"resources/images/indexMap/drought_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_8_4",value:"resources/images/indexMap/drought_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_9_2",value:"resources/images/indexMap/lightning_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_9_3",value:"resources/images/indexMap/lightning_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_9_4",value:"resources/images/indexMap/lightning_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_10_3",value:"resources/images/indexMap/hail_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_10_4",value:"resources/images/indexMap/hail_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_11_1",value:"resources/images/indexMap/frost_blue.jpg",rotation:false,width:25,height:25},
			{name:"yj_11_2",value:"resources/images/indexMap/frost_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_11_3",value:"resources/images/indexMap/frost_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_2_1",value:"resources/images/indexMap/rainstorm_blue.jpg",rotation:false,width:25,height:25},
			{name:"yj_2_2",value:"resources/images/indexMap/rainstorm_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_2_3",value:"resources/images/indexMap/rainstorm_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_2_4",value:"resources/images/indexMap/rainstorm_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_3_1",value:"resources/images/indexMap/snowstorm_blue.jpg",rotation:false,width:25,height:25},
			{name:"yj_3_2",value:"resources/images/indexMap/snowstorm_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_3_3",value:"resources/images/indexMap/snowstorm_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_3_4",value:"resources/images/indexMap/snowstorm_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_4_1",value:"resources/images/indexMap/coldwave_blue.jpg",rotation:false,width:25,height:25},
			{name:"yj_4_2",value:"resources/images/indexMap/coldwave_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_4_3",value:"resources/images/indexMap/coldwave_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_4_4",value:"resources/images/indexMap/coldwave_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_1_1",value:"resources/images/indexMap/typhoon_blue.jpg",rotation:false,width:25,height:25},
			{name:"yj_5_1",value:"resources/images/indexMap/gale_blue.jpg",rotation:false,width:25,height:25},
			{name:"yj_5_2",value:"resources/images/indexMap/gale_yellow.jpg",rotation:false,width:25,height:25},
			{name:"yj_5_3",value:"resources/images/indexMap/gale_orange.jpg",rotation:false,width:25,height:25},
			{name:"yj_5_4",value:"resources/images/indexMap/gale_red.jpg",rotation:false,width:25,height:25},
			{name:"yj_6_2",value:"resources/images/indexMap/shachengbao_yellow.jpg",rotation:false,width:25,height:25}
		]
	}
};
jQuery(function(){//页面初始化
	var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("#weekr").append(loading);
	addWeekWarning();
});

function messages(){
	var monthRecords = document.getElementById ("monthRecords").innerHTML;
	if(monthRecords=="--"){
		addMonthWarning();
	}
}

function settings(){
	var yearRecords = document.getElementById ("yearRecords").innerHTML;
	if(yearRecords=="--"){
		addYearWarning();
	}
}

//获取本周预警信息
function addWeekWarning(){
	var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("#weekr").append(loading);
	//获取本周时间
	//按周日为一周的最后一天计算
    var date = new Date();

    //今天是这周的第几天
    var today = date.getDay();

    //上周日距离今天的天数（负数表示）
    var stepSunDay = -today + 1;

    // 如果今天是周日
    if (today == 0) {

        stepSunDay = -7;
    }

    // 周一距离今天的天数（负数表示）
    var stepMonday = 7 - today;

    var time = date.getTime();

    var monday = new Date(time + stepSunDay * 24 * 3600 * 1000);
    var sunday = new Date(time + stepMonday * 24 * 3600 * 1000);

    //本周一的日期 （起始日期）
    var startDate = transferDate(monday); // 日期变换
    //本周日的日期 （结束日期）
    var endDate = transferDate(sunday); // 日期变换
	//alert(startDate+" - "+endDate);
	var params = {
		"sendtimestart" : startDate,     
        "sendtimestop" : endDate,
		"rows" : 5
	};
	$.ajax({
		url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
		type : "post",
		datatype: "json",
		async: true,
		data:params,
		success: function(jsons){
			//获取总条数
			document.getElementById ("weekRecords").innerHTML = jsons.records;
			//获取当前页码
			document.getElementById ("weekCurrPage").innerHTML = jsons.page;
			//获取总页数
			document.getElementById ("weekTotalPages").innerHTML = jsons.total;
			//事件类别名称数组
			var productNameArray = new Array();
			var li = "";
			for(var i in jsons.rows){
				//将事件类别编码转成事件类别名称
				if(jsons.rows[i].eventType!=undefined){
					$.ajax({
						async: false,
						data:{"productcode":jsons.rows[i].eventType},
						url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
						success: function(data){
							productNameArray[i] = data.productName;
						},
						error: function (xhr) { console.log('加载事件类别出错！'); }
					}); 
				}else{
					productNameArray[i] = "";
				}
				var levelName = "未知";
				if(jsons.rows[i].alamlevels.alamlevelName!=""){
					levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
				}
				var processName = "";
				if(jsons.rows[i].processStatuss!=undefined){
					processName = jsons.rows[i].processStatuss.statusName;
				}
				
				//获取预警信息发布类型
				var leixing = "";
				if(jsons.rows[i].alerts.status==="0"){
					leixing = "实际预警";
				}else if(jsons.rows[i].alerts.status=="1"){
					leixing = "测试预警";
				}
				
				var imgFlag = "";
				var imgUrl = "";
				var title = jsons.rows[i].headline;
				for(var j=0; j<Global.monitor.yjxh.length; j++){
					if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
						imgFlag = Global.monitor.yjxh[j].flag;
						break;
					}
				}
				for(var j=0; j<Global.monitor.imgUrl.length; j++){
					if(imgFlag == Global.monitor.imgUrl[j].name){
						imgUrl = Global.monitor.imgUrl[j].value;
						break;
					}
				}
				if(imgUrl == ""){
					if(typeof title == "string" && title.indexOf("蓝色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_blue.png";
					}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_yellow.png";
					}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_orange.png";
					}else if(typeof title == "string" && title.indexOf("红色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_red.png";
					}
				}
				
				li += "<li class=\"warning-list\">"+
                    "<div class=\"warning-con\">"+
                        "<div class=\"warning-time\">"+
                            "<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
                            "<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
                            "<span class=\"warning-effect\">["+processName+"]</span>"+
                        "</div>"+
                        "<div class=\"warning-text-con\">"+
                            "<img src=\"../"+imgUrl+"\" alt=\"\">"+
                            "<div class=\"warning-text\">"+
                                "<strong>["+jsons.rows[i].headline+"]</strong>"+
                                jsons.rows[i].description+
                            "</div>";
							if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
								li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
									"编辑预警"+
								"</div>";
							}else{
								li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
									"查看详情"+
								"</div>";
							}
                        li += "</div>"+
                        "<div class=\"warning-infos\">"+
                            "<ul>"+
                                "<li>"+
                                    "<span class=\"info-text\">事件类别:</span>"+
                                    "<span class=\"info-content\">"+productNameArray[i]+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">预警级别:</span>"+
                                    "<span class=\"info-content\">"+levelName+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">发布时间:</span>"+
                                    "<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">发布单位:</span>"+
                                    "<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
                                "</li>"+
								"<li>"+
                                    "<span class=\"info-text\">发布类型:</span>"+
                                    "<span class=\"info-content\">"+leixing+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">影响区域:</span>"+
                                    "<span class=\"info-content\">"+
                                        jsons.rows[i].areadesc+
                                    "</span>"+
                                "</li>"+
                            "</ul>"+
                        "</div>"+
                    "</div>"+
                "</li>";
				document.getElementById('weekWarningUl').innerHTML = li;

			}
			if ($("#profilea").ready){
				$(".loading").fadeOut();
			};
		},
		error: function (xhr) {
			alert('系统错误，请联系管理员！！');
			if ($("#profilea").ready){
				$(".loading").fadeOut();
			};
		}
	});
}
//获取本月预警信息
function addMonthWarning(){
	var loading2 = '<div class="loading2"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("#monr").append(loading2);

	//获取本月时间
	// 获取当前月的第一天  
    var start = new Date();  
    start.setDate(1);  
  
    // 获取当前月的最后一天  
    var date = new Date();  
    var currentMonth = date.getMonth();  
    var nextMonth = ++currentMonth;  
    var nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1);  
    var oneDay = 1000 * 60 * 60 * 24;  
    var end = new Date(nextMonthFirstDay - oneDay);  
  
    var startDate = transferDate(start); // 日期变换  
    var endDate = transferDate(end); // 日期变换
	//alert(startDate+" - "+endDate);
	var params = {
		"sendtimestart" : startDate,     
        "sendtimestop" : endDate,
		"rows" : 5
	};


	$.ajax({
		url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
		type : "post",
		datatype: "json",
		async: true,
		data:params,
		success: function(jsons){
			//获取总条数
			document.getElementById ("monthRecords").innerHTML = jsons.records;
			//获取当前页码
			document.getElementById ("monthCurrPage").innerHTML = jsons.page;
			//获取总页数
			document.getElementById ("monthTotalPages").innerHTML = jsons.total;
			//事件类别名称数组
			var productNameArray = new Array();
			var li = "";
			for(var i in jsons.rows){
				//将事件类别编码转成事件类别名称
				if(jsons.rows[i].eventType!=undefined){
					$.ajax({
						async: false,
						data:{"productcode":jsons.rows[i].eventType},
						url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
						success: function(data){
							productNameArray[i] = data.productName;
						},
						error: function (xhr) { console.log('加载事件类别出错！'); }
					}); 
				}else{
					productNameArray[i] = "";
				}
				var levelName = "未知";
				if(jsons.rows[i].alamlevels.alamlevelName!=""){
					levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
				}
				
				//获取预警信息发布类型
				var leixing = "";
				if(jsons.rows[i].alerts.status==="0"){
					leixing = "实际预警";
				}else if(jsons.rows[i].alerts.status=="1"){
					leixing = "测试预警";
				}
				
				var processName = "";
				if(jsons.rows[i].processStatuss!=undefined){
					processName = jsons.rows[i].processStatuss.statusName;
				}
				
				var imgFlag = "";
				var imgUrl = "";
				var title = jsons.rows[i].headline;
				for(var j=0; j<Global.monitor.yjxh.length; j++){
					if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
						imgFlag = Global.monitor.yjxh[j].flag;
						break;
					}
				}
				for(var j=0; j<Global.monitor.imgUrl.length; j++){
					if(imgFlag == Global.monitor.imgUrl[j].name){
						imgUrl = Global.monitor.imgUrl[j].value;
						break;
					}
				}
				if(imgUrl == ""){
					if(typeof title == "string" && title.indexOf("蓝色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_blue.png";
					}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_yellow.png";
					}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_orange.png";
					}else if(typeof title == "string" && title.indexOf("红色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_red.png";
					}
				}
				
				li += "<li class=\"warning-list\">"+
                    "<div class=\"warning-con\">"+
                        "<div class=\"warning-time\">"+
                            "<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
                            "<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
                            "<span class=\"warning-effect\">["+processName+"]</span>"+
                        "</div>"+
                        "<div class=\"warning-text-con\">"+
                            "<img src=\"../"+imgUrl+"\" alt=\"\">"+
                            "<div class=\"warning-text\">"+
                                "<strong>["+jsons.rows[i].headline+"]</strong>"+
                                jsons.rows[i].description+
                            "</div>";
							if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
								li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
									"编辑预警"+
								"</div>";
							}else{
								li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
									"查看详情"+
								"</div>";
							}
                        li += "</div>"+
                        "<div class=\"warning-infos\">"+
                            "<ul>"+
                                "<li>"+
                                    "<span class=\"info-text\">事件类别:</span>"+
                                    "<span class=\"info-content\">"+productNameArray[i]+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">预警级别:</span>"+
                                    "<span class=\"info-content\">"+levelName+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">发布时间:</span>"+
                                    "<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">发布单位:</span>"+
                                    "<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
                                "</li>"+
								"<li>"+
                                    "<span class=\"info-text\">发布类型:</span>"+
                                    "<span class=\"info-content\">"+leixing+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">影响区域:</span>"+
                                    "<span class=\"info-content\">"+
                                        jsons.rows[i].areadesc+
                                    "</span>"+
                                "</li>"+
                            "</ul>"+
                        "</div>"+
                    "</div>"+
                "</li>";
				document.getElementById('monthWarningUl').innerHTML = li;

			}
			if ($("#messagesa").ready){
				$(".loading2").fadeOut();
			};
		},
		error: function (xhr) {
			alert('系统错误，请联系管理员！！');
			if ($("#messagesa").ready){
				$(".loading2").fadeOut();
			};
		}
	});

}

//获取本年度预警信息
function addYearWarning(){
	var loading3 = '<div class="loading3"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("#yearr").append(loading3);
	//获取本年时间  
    var systemDate = new Date();  
    // 获取当年    
    var year = systemDate.getFullYear(); 

    var startDate = year+"-01-01 00:00:00";
    var endDate = year+"-12-31 00:00:00";
	//alert(startDate+" - "+endDate);
	var params = {
		"sendtimestart" : startDate,     
        "sendtimestop" : endDate,
		"rows" : 5
	};
	$.ajax({
		url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
		type : "post",
		datatype: "json",
		async: true,
		data:params,
		success: function(jsons){
			//获取总条数
			document.getElementById ("yearRecords").innerHTML = jsons.records;
			//获取当前页码
			document.getElementById ("yearCurrPage").innerHTML = jsons.page;
			//获取总页数
			document.getElementById ("yearTotalPages").innerHTML = jsons.total;
			//事件类别名称数组
			var productNameArray = new Array();
			var li = "";
			for(var i in jsons.rows){
				//将事件类别编码转成事件类别名称
				if(jsons.rows[i].eventType!=undefined){
					$.ajax({
						async: false,
						data:{"productcode":jsons.rows[i].eventType},
						url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
						success: function(data){
							productNameArray[i] = data.productName;
						},
						error: function (xhr) { console.log('加载事件类别出错！'); }
					}); 
				}else{
					productNameArray[i] = "";
				}
				var levelName = "未知";
				if(jsons.rows[i].alamlevels.alamlevelName!=""){
					levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
				}
				
				//获取预警信息发布类型
				var leixing = "";
				if(jsons.rows[i].alerts.status==="0"){
					leixing = "实际预警";
				}else if(jsons.rows[i].alerts.status=="1"){
					leixing = "测试预警";
				}
				
				var processName = "";
				if(jsons.rows[i].processStatuss!=undefined){
					processName = jsons.rows[i].processStatuss.statusName;
				}
				
				var imgFlag = "";
				var imgUrl = "";
				var title = jsons.rows[i].headline;
				for(var j=0; j<Global.monitor.yjxh.length; j++){
					if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
						imgFlag = Global.monitor.yjxh[j].flag;
						break;
					}
				}
				for(var j=0; j<Global.monitor.imgUrl.length; j++){
					if(imgFlag == Global.monitor.imgUrl[j].name){
						imgUrl = Global.monitor.imgUrl[j].value;
						break;
					}
				}
				if(imgUrl == ""){
					if(typeof title == "string" && title.indexOf("蓝色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_blue.png";
					}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_yellow.png";
					}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_orange.png";
					}else if(typeof title == "string" && title.indexOf("红色") >= 0){
						imgUrl = "resources/images/indexMap/adefault_red.png";
					}
				}
				
				li += "<li class=\"warning-list\">"+
                    "<div class=\"warning-con\">"+
                        "<div class=\"warning-time\">"+
                            "<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
                            "<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
                            "<span class=\"warning-effect\">["+processName+"]</span>"+
                        "</div>"+
                        "<div class=\"warning-text-con\">"+
                            "<img src=\"../"+imgUrl+"\" alt=\"\">"+
                            "<div class=\"warning-text\">"+
                                "<strong>["+jsons.rows[i].headline+"]</strong>"+
                                jsons.rows[i].description+
                            "</div>";
							if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
								li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
									"编辑预警"+
								"</div>";
							}else{
								li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
									"查看详情"+
								"</div>";
							}
                        li += "</div>"+
                        "<div class=\"warning-infos\">"+
                            "<ul>"+
                                "<li>"+
                                    "<span class=\"info-text\">事件类别:</span>"+
                                    "<span class=\"info-content\">"+productNameArray[i]+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">预警级别:</span>"+
                                    "<span class=\"info-content\">"+levelName+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">发布时间:</span>"+
                                    "<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">发布单位:</span>"+
                                    "<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
                                "</li>"+
								"<li>"+
                                    "<span class=\"info-text\">发布类型:</span>"+
                                    "<span class=\"info-content\">"+leixing+"</span>"+
                                "</li>"+
                                "<li>"+
                                    "<span class=\"info-text\">影响区域:</span>"+
                                    "<span class=\"info-content\">"+
                                        jsons.rows[i].areadesc+
                                    "</span>"+
                                "</li>"+
                            "</ul>"+
                        "</div>"+
                    "</div>"+
                "</li>";
				document.getElementById('yearWarningUl').innerHTML = li;

			}
			if ($("#settingsa").ready){
				$(".loading3").fadeOut();
			};
		},
		error: function (xhr) {
			alert('系统错误，请联系管理员！！');
			if ($("#settingsa").ready){
				$(".loading3").fadeOut();
			};
		}
	});

}

//5.日期变换的方法
function transferDate(date) {  
  
    // 年  
    var year = date.getFullYear();  
    // 月  
    var month = date.getMonth() + 1;  
    // 日  
    var day = date.getDate();  
  
    if (month >= 1 && month <= 9) {  
  
        month = "0" + month;  
    }  
    if (day >= 0 && day <= 9) {  
  
        day = "0" + day;  
    }  
  
    var dateString = year + '-' + month + '-' + day+" 00:00:00";  
  
    return dateString;  
}


//本周预警上一页
function upWeekPage(){
	var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("body").append(loading);
	var currPage = document.getElementById ("weekCurrPage").innerHTML;
	if(currPage==1){
		alert("当前在第一页！");
		$(".loading").fadeOut();

	}else{
		//获取本周时间
		//按周日为一周的最后一天计算
		var date = new Date();

		//今天是这周的第几天
		var today = date.getDay();

		//上周日距离今天的天数（负数表示）
		var stepSunDay = -today + 1;

		// 如果今天是周日
		if (today == 0) {

			stepSunDay = -7;
		}

		// 周一距离今天的天数（负数表示）
		var stepMonday = 7 - today;

		var time = date.getTime();

		var monday = new Date(time + stepSunDay * 24 * 3600 * 1000);
		var sunday = new Date(time + stepMonday * 24 * 3600 * 1000);

		//本周一的日期 （起始日期）
		var startDate = transferDate(monday); // 日期变换
		//本周日的日期 （结束日期）
		var endDate = transferDate(sunday); // 日期变换
		$.ajax({
			url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
			type : "post",
			datatype: "json",
			async: false,
			data:{
				sendtimestart : startDate,     
				sendtimestop : endDate,
				page : parseInt(currPage)-1,
				rows : 5
			},
			success: function(jsons){
				//获取当前页码
				document.getElementById ("weekCurrPage").innerHTML = jsons.page;
				//获取总页数
				document.getElementById ("weekTotalPages").innerHTML = jsons.total;
				//事件类别名称数组
				var productNameArray = new Array();
				//翻页前删除原页面加载的数据
				document.getElementById('weekWarningUl').innerHTML = "";
				var li = "";
				for(var i in jsons.rows){
					//将事件类别编码转成事件类别名称
					if(jsons.rows[i].eventType!=undefined){
						$.ajax({
							async: true,
							data:{"productcode":jsons.rows[i].eventType},
							url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
							success: function(data){
								productNameArray[i] = data.productName;
							},
							error: function (xhr) { console.log('加载事件类别出错！'); }
						}); 
					}else{
						productNameArray[i] = "";
					}
					var levelName = "未知";
					if(jsons.rows[i].alamlevels.alamlevelName!=""){
						levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
					}
					
					//获取预警信息发布类型
					var leixing = "";
					if(jsons.rows[i].alerts.status==="0"){
						leixing = "实际预警";
					}else if(jsons.rows[i].alerts.status=="1"){
						leixing = "测试预警";
					}
					
					var processName = "";
					if(jsons.rows[i].processStatuss!=undefined){
						processName = jsons.rows[i].processStatuss.statusName;
					}
					
					var imgFlag = "";
					var imgUrl = "";
					var title = jsons.rows[i].headline;
					for(var j=0; j<Global.monitor.yjxh.length; j++){
						if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
							imgFlag = Global.monitor.yjxh[j].flag;
							break;
						}
					}
					for(var j=0; j<Global.monitor.imgUrl.length; j++){
						if(imgFlag == Global.monitor.imgUrl[j].name){
							imgUrl = Global.monitor.imgUrl[j].value;
							break;
						}
					}
					if(imgUrl == ""){
						if(typeof title == "string" && title.indexOf("蓝色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_blue.png";
						}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_yellow.png";
						}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_orange.png";
						}else if(typeof title == "string" && title.indexOf("红色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_red.png";
						}
					}
					
					li += "<li class=\"warning-list\">"+
						"<div class=\"warning-con\">"+
							"<div class=\"warning-time\">"+
								"<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
								"<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
								"<span class=\"warning-effect\">["+processName+"]</span>"+
							"</div>"+
							"<div class=\"warning-text-con\">"+
								"<img src=\"../"+imgUrl+"\" alt=\"\">"+
								"<div class=\"warning-text\">"+
									"<strong>["+jsons.rows[i].headline+"]</strong>"+
									jsons.rows[i].description+
								"</div>";
								if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
									li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
										"编辑预警"+
									"</div>";
								}else{
									li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
										"查看详情"+
									"</div>";
								}
							li += "</div>"+
							"<div class=\"warning-infos\">"+
								"<ul>"+
									"<li>"+
										"<span class=\"info-text\">事件类别:</span>"+
										"<span class=\"info-content\">"+productNameArray[i]+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">预警级别:</span>"+
										"<span class=\"info-content\">"+levelName+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布时间:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布单位:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布类型:</span>"+
										"<span class=\"info-content\">"+leixing+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">影响区域:</span>"+
										"<span class=\"info-content\">"+
											jsons.rows[i].areadesc+
										"</span>"+
									"</li>"+
								"</ul>"+
							"</div>"+
						"</div>"+
					"</li>";
					document.getElementById('weekWarningUl').innerHTML = li;
				}
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			},
			error: function (xhr) {
				alert('系统错误，请联系管理员！！');
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			}
		});
		//返回页面顶端
		scrollTo(0,0);
	}
}

//本月预警上一页
function upMonthPage(){
	var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("body").append(loading);
	var currPage = document.getElementById ("monthCurrPage").innerHTML;
	if(currPage==1){
		alert("当前在第一页！");
		$(".loading").fadeOut();
	}else{
		//获取本月时间
		// 获取当前月的第一天  
		var start = new Date();  
		start.setDate(1);  
	  
		// 获取当前月的最后一天  
		var date = new Date();  
		var currentMonth = date.getMonth();  
		var nextMonth = ++currentMonth;  
		var nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1);  
		var oneDay = 1000 * 60 * 60 * 24;  
		var end = new Date(nextMonthFirstDay - oneDay);  
	  
		var startDate = transferDate(start); // 日期变换  
		var endDate = transferDate(end); // 日期变换
		$.ajax({
			url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
			type : "post",
			datatype: "json",
			async: true,
			data:{
				sendtimestart : startDate,     
				sendtimestop : endDate,
				page : parseInt(currPage)-1,
				rows : 5
			},
			success: function(jsons){
				//获取当前页码
				document.getElementById ("monthCurrPage").innerHTML = jsons.page;
				//获取总页数
				document.getElementById ("monthTotalPages").innerHTML = jsons.total;
				//事件类别名称数组
				var productNameArray = new Array();
				//翻页前删除原页面加载的数据
				document.getElementById('monthWarningUl').innerHTML = "";
				var li = "";
				for(var i in jsons.rows){
					//将事件类别编码转成事件类别名称
					if(jsons.rows[i].eventType!=undefined){
						$.ajax({
							async: false,
							data:{"productcode":jsons.rows[i].eventType},
							url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
							success: function(data){
								productNameArray[i] = data.productName;
							},
							error: function (xhr) { console.log('加载事件类别出错！'); }
						}); 
					}else{
						productNameArray[i] = "";
					}
					var levelName = "未知";
					if(jsons.rows[i].alamlevels.alamlevelName!=""){
						levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
					}
					
					//获取预警信息发布类型
					var leixing = "";
					if(jsons.rows[i].alerts.status==="0"){
						leixing = "实际预警";
					}else if(jsons.rows[i].alerts.status=="1"){
						leixing = "测试预警";
					}
					
					var processName = "";
					if(jsons.rows[i].processStatuss!=undefined){
						processName = jsons.rows[i].processStatuss.statusName;
					}
					
					var imgFlag = "";
					var imgUrl = "";
					var title = jsons.rows[i].headline;
					for(var j=0; j<Global.monitor.yjxh.length; j++){
						if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
							imgFlag = Global.monitor.yjxh[j].flag;
							break;
						}
					}
					for(var j=0; j<Global.monitor.imgUrl.length; j++){
						if(imgFlag == Global.monitor.imgUrl[j].name){
							imgUrl = Global.monitor.imgUrl[j].value;
							break;
						}
					}
					if(imgUrl == ""){
						if(typeof title == "string" && title.indexOf("蓝色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_blue.png";
						}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_yellow.png";
						}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_orange.png";
						}else if(typeof title == "string" && title.indexOf("红色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_red.png";
						}
					}
					
					li += "<li class=\"warning-list\">"+
						"<div class=\"warning-con\">"+
							"<div class=\"warning-time\">"+
								"<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
								"<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
								"<span class=\"warning-effect\">["+processName+"]</span>"+
							"</div>"+
							"<div class=\"warning-text-con\">"+
								"<img src=\"../"+imgUrl+"\" alt=\"\">"+
								"<div class=\"warning-text\">"+
									"<strong>["+jsons.rows[i].headline+"]</strong>"+
									jsons.rows[i].description+
								"</div>";
								if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
									li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
										"编辑预警"+
									"</div>";
								}else{
									li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
										"查看详情"+
									"</div>";
								}
							li += "</div>"+
							"<div class=\"warning-infos\">"+
								"<ul>"+
									"<li>"+
										"<span class=\"info-text\">事件类别:</span>"+
										"<span class=\"info-content\">"+productNameArray[i]+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">预警级别:</span>"+
										"<span class=\"info-content\">"+levelName+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布时间:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布单位:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布类型:</span>"+
										"<span class=\"info-content\">"+leixing+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">影响区域:</span>"+
										"<span class=\"info-content\">"+
											jsons.rows[i].areadesc+
										"</span>"+
									"</li>"+
								"</ul>"+
							"</div>"+
						"</div>"+
					"</li>";
					document.getElementById('monthWarningUl').innerHTML = li;
				}
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			},
			error: function (xhr) {
				alert('系统错误，请联系管理员！！');
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			}
		});
		//返回页面顶端
		scrollTo(0,0);
	}
}

//本年度预警上一页
function upYearPage(){
	var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("body").append(loading);
	var currPage = document.getElementById("yearCurrPage").innerHTML;
	if(currPage==1){
		alert("当前在第一页！");
		$(".loading").fadeOut();

	}else{
		//获取本年时间  
		var systemDate = new Date();  
		// 获取当年    
		var year = systemDate.getFullYear(); 

		var startDate = year+"-01-01 00:00:00";
		var endDate = year+"-12-31 00:00:00";
		$.ajax({
			url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
			type : "post",
			datatype: "json",
			async: true,
			data:{
				sendtimestart : startDate,     
				sendtimestop : endDate,
				page : parseInt(currPage)-1,
				rows : 5
			},
			success: function(jsons){
				//获取当前页码
				document.getElementById ("yearCurrPage").innerHTML = jsons.page;
				//获取总页数
				document.getElementById ("yearTotalPages").innerHTML = jsons.total;
				//事件类别名称数组
				var productNameArray = new Array();
				//翻页前删除原页面加载的数据
				document.getElementById('yearWarningUl').innerHTML = "";
				var li = "";
				for(var i in jsons.rows){
					//将事件类别编码转成事件类别名称
					if(jsons.rows[i].eventType!=undefined){
						$.ajax({
							async: false,
							data:{"productcode":jsons.rows[i].eventType},
							url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
							success: function(data){
								productNameArray[i] = data.productName;
							},
							error: function (xhr) { console.log('加载事件类别出错！'); }
						}); 
					}else{
						productNameArray[i] = "";
					}
					var levelName = "未知";
					if(jsons.rows[i].alamlevels.alamlevelName!=""){
						levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
					}
					
					//获取预警信息发布类型
					var leixing = "";
					if(jsons.rows[i].alerts.status==="0"){
						leixing = "实际预警";
					}else if(jsons.rows[i].alerts.status=="1"){
						leixing = "测试预警";
					}
					
					var processName = "";
					if(jsons.rows[i].processStatuss!=undefined){
						processName = jsons.rows[i].processStatuss.statusName;
					}
					
					var imgFlag = "";
					var imgUrl = "";
					var title = jsons.rows[i].headline;
					for(var j=0; j<Global.monitor.yjxh.length; j++){
						if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
							imgFlag = Global.monitor.yjxh[j].flag;
							break;
						}
					}
					for(var j=0; j<Global.monitor.imgUrl.length; j++){
						if(imgFlag == Global.monitor.imgUrl[j].name){
							imgUrl = Global.monitor.imgUrl[j].value;
							break;
						}
					}
					if(imgUrl == ""){
						if(typeof title == "string" && title.indexOf("蓝色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_blue.png";
						}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_yellow.png";
						}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_orange.png";
						}else if(typeof title == "string" && title.indexOf("红色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_red.png";
						}
					}
					
					li += "<li class=\"warning-list\">"+
						"<div class=\"warning-con\">"+
							"<div class=\"warning-time\">"+
								"<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
								"<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
								"<span class=\"warning-effect\">["+processName+"]</span>"+
							"</div>"+
							"<div class=\"warning-text-con\">"+
								"<img src=\"../"+imgUrl+"\" alt=\"\">"+
								"<div class=\"warning-text\">"+
									"<strong>["+jsons.rows[i].headline+"]</strong>"+
									jsons.rows[i].description+
								"</div>";
								if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
									li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
										"编辑预警"+
									"</div>";
								}else{
									li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
										"查看详情"+
									"</div>";
								}
							li += "</div>"+
							"<div class=\"warning-infos\">"+
								"<ul>"+
									"<li>"+
										"<span class=\"info-text\">事件类别:</span>"+
										"<span class=\"info-content\">"+productNameArray[i]+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">预警级别:</span>"+
										"<span class=\"info-content\">"+levelName+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布时间:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布单位:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布类型:</span>"+
										"<span class=\"info-content\">"+leixing+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">影响区域:</span>"+
										"<span class=\"info-content\">"+
											jsons.rows[i].areadesc+
										"</span>"+
									"</li>"+
								"</ul>"+
							"</div>"+
						"</div>"+
					"</li>";
					document.getElementById('yearWarningUl').innerHTML = li;
				}
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			},
			error: function (xhr) {
				alert('系统错误，请联系管理员！！');
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			}
		});
		//返回页面顶端
		scrollTo(0,0);
	}
}

//本周预警下一页
function downWeekPage(){
	var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("body").append(loading);
	var currPage = document.getElementById ("weekCurrPage").innerHTML;
	var totalPages = document.getElementById ("weekTotalPages").innerHTML;
	if(currPage==totalPages){
		alert("已经在最后一页！");
		$(".loading").fadeOut();
	}else{
		//获取本周时间
		//按周日为一周的最后一天计算
		var date = new Date();

		//今天是这周的第几天
		var today = date.getDay();

		//上周日距离今天的天数（负数表示）
		var stepSunDay = -today + 1;

		// 如果今天是周日
		if (today == 0) {

			stepSunDay = -7;
		}

		// 周一距离今天的天数（负数表示）
		var stepMonday = 7 - today;

		var time = date.getTime();

		var monday = new Date(time + stepSunDay * 24 * 3600 * 1000);
		var sunday = new Date(time + stepMonday * 24 * 3600 * 1000);

		//本周一的日期 （起始日期）
		var startDate = transferDate(monday); // 日期变换
		//本周日的日期 （结束日期）
		var endDate = transferDate(sunday); // 日期变换
		$.ajax({
			url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
			type : "post",
			datatype: "json",
			async: true,
			data:{
				sendtimestart : startDate,
				sendtimestop : endDate,
				page : parseInt(currPage)+1,
				rows : 5
			},
			success: function(jsons){
				//获取当前页码
				document.getElementById ("weekCurrPage").innerHTML = jsons.page;
				//获取总页数
				document.getElementById ("weekTotalPages").innerHTML = jsons.total;
				//事件类别名称数组
				var productNameArray = new Array();
				//翻页前删除原页面加载的数据
				document.getElementById('weekWarningUl').innerHTML = "";
				var li = "";
				for(var i in jsons.rows){
					//将事件类别编码转成事件类别名称
					if(jsons.rows[i].eventType!=undefined){
						$.ajax({
							async: false,
							data:{"productcode":jsons.rows[i].eventType},
							url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
							success: function(data){
								productNameArray[i] = data.productName;
							},
							error: function (xhr) { console.log('加载事件类别出错！'); }
						}); 
					}else{
						productNameArray[i] = "";
					}
					var levelName = "未知";
					if(jsons.rows[i].alamlevels.alamlevelName!=""){
						levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
					}
					
					//获取预警信息发布类型
					var leixing = "";
					if(jsons.rows[i].alerts.status==="0"){
						leixing = "实际预警";
					}else if(jsons.rows[i].alerts.status=="1"){
						leixing = "测试预警";
					}
					
					var processName = "";
					if(jsons.rows[i].processStatuss!=undefined){
						processName = jsons.rows[i].processStatuss.statusName;
					}
					
					var imgFlag = "";
					var imgUrl = "";
					var title = jsons.rows[i].headline;
					for(var j=0; j<Global.monitor.yjxh.length; j++){
						if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
							imgFlag = Global.monitor.yjxh[j].flag;
							break;
						}
					}
					for(var j=0; j<Global.monitor.imgUrl.length; j++){
						if(imgFlag == Global.monitor.imgUrl[j].name){
							imgUrl = Global.monitor.imgUrl[j].value;
							break;
						}
					}
					if(imgUrl == ""){
						if(typeof title == "string" && title.indexOf("蓝色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_blue.png";
						}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_yellow.png";
						}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_orange.png";
						}else if(typeof title == "string" && title.indexOf("红色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_red.png";
						}
					}
					
					li += "<li class=\"warning-list\">"+
						"<div class=\"warning-con\">"+
							"<div class=\"warning-time\">"+
								"<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
								"<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
								"<span class=\"warning-effect\">["+processName+"]</span>"+
							"</div>"+
							"<div class=\"warning-text-con\">"+
								"<img src=\"../"+imgUrl+"\" alt=\"\">"+
								"<div class=\"warning-text\">"+
									"<strong>["+jsons.rows[i].headline+"]</strong>"+
									jsons.rows[i].description+
								"</div>";
								if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
									li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
										"编辑预警"+
									"</div>";
								}else{
									li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
										"查看详情"+
									"</div>";
								}
							li += "</div>"+
							"<div class=\"warning-infos\">"+
								"<ul>"+
									"<li>"+
										"<span class=\"info-text\">事件类别:</span>"+
										"<span class=\"info-content\">"+productNameArray[i]+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">预警级别:</span>"+
										"<span class=\"info-content\">"+levelName+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布时间:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布单位:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布类型:</span>"+
										"<span class=\"info-content\">"+leixing+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">影响区域:</span>"+
										"<span class=\"info-content\">"+
											jsons.rows[i].areadesc+
										"</span>"+
									"</li>"+
								"</ul>"+
							"</div>"+
						"</div>"+
					"</li>";
					document.getElementById('weekWarningUl').innerHTML = li;
				}
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			},
			error: function (xhr) {
				alert('系统错误，请联系管理员！！');
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			}
		});
		//返回页面顶端
		scrollTo(0,0);
	}
}

//本月预警下一页
function downMonthPage(){
	var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("body").append(loading);
	var currPage = document.getElementById ("monthCurrPage").innerHTML;
	var totalPages = document.getElementById ("monthTotalPages").innerHTML;
	if(currPage==totalPages){
		alert("已经在最后一页！");
		$(".loading").fadeOut();
	}else{
		//获取本月时间
		// 获取当前月的第一天  
		var start = new Date();  
		start.setDate(1);  
	  
		// 获取当前月的最后一天  
		var date = new Date();  
		var currentMonth = date.getMonth();  
		var nextMonth = ++currentMonth;  
		var nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1);  
		var oneDay = 1000 * 60 * 60 * 24;  
		var end = new Date(nextMonthFirstDay - oneDay);  
	  
		var startDate = transferDate(start); // 日期变换  
		var endDate = transferDate(end); // 日期变换
		$.ajax({
			url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
			type : "post",
			datatype: "json",
			async: true,
			data:{
				sendtimestart : startDate,
				sendtimestop : endDate,
				page : parseInt(currPage)+1,
				rows : 5
			},
			success: function(jsons){
				//获取当前页码
				document.getElementById ("monthCurrPage").innerHTML = jsons.page;
				//获取总页数
				document.getElementById ("monthTotalPages").innerHTML = jsons.total;
				//事件类别名称数组
				var productNameArray = new Array();
				//翻页前删除原页面加载的数据
				document.getElementById('monthWarningUl').innerHTML = "";
				var li = "";
				for(var i in jsons.rows){
					//将事件类别编码转成事件类别名称
					if(jsons.rows[i].eventType!=undefined){
						$.ajax({
							async: false,
							data:{"productcode":jsons.rows[i].eventType},
							url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
							success: function(data){
								productNameArray[i] = data.productName;
							},
							error: function (xhr) { console.log('加载事件类别出错！'); }
						}); 
					}else{
						productNameArray[i] = "";
					}
					var levelName = "未知";
					if(jsons.rows[i].alamlevels.alamlevelName!=""){
						levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
					}
					
					//获取预警信息发布类型
					var leixing = "";
					if(jsons.rows[i].alerts.status==="0"){
						leixing = "实际预警";
					}else if(jsons.rows[i].alerts.status=="1"){
						leixing = "测试预警";
					}
					
					var processName = "";
					if(jsons.rows[i].processStatuss!=undefined){
						processName = jsons.rows[i].processStatuss.statusName;
					}
					
					var imgFlag = "";
					var imgUrl = "";
					var title = jsons.rows[i].headline;
					for(var j=0; j<Global.monitor.yjxh.length; j++){
						if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
							imgFlag = Global.monitor.yjxh[j].flag;
							break;
						}
					}
					for(var j=0; j<Global.monitor.imgUrl.length; j++){
						if(imgFlag == Global.monitor.imgUrl[j].name){
							imgUrl = Global.monitor.imgUrl[j].value;
							break;
						}
					}
					if(imgUrl == ""){
						if(typeof title == "string" && title.indexOf("蓝色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_blue.png";
						}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_yellow.png";
						}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_orange.png";
						}else if(typeof title == "string" && title.indexOf("红色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_red.png";
						}
					}
					
					li += "<li class=\"warning-list\">"+
						"<div class=\"warning-con\">"+
							"<div class=\"warning-time\">"+
								"<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
								"<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
								"<span class=\"warning-effect\">["+processName+"]</span>"+
							"</div>"+
							"<div class=\"warning-text-con\">"+
								"<img src=\"../"+imgUrl+"\" alt=\"\">"+
								"<div class=\"warning-text\">"+
									"<strong>["+jsons.rows[i].headline+"]</strong>"+
									jsons.rows[i].description+
								"</div>";
								if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
									li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
										"编辑预警"+
									"</div>";
								}else{
									li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
										"查看详情"+
									"</div>";
								}
							li += "</div>"+
							"<div class=\"warning-infos\">"+
								"<ul>"+
									"<li>"+
										"<span class=\"info-text\">事件类别:</span>"+
										"<span class=\"info-content\">"+productNameArray[i]+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">预警级别:</span>"+
										"<span class=\"info-content\">"+levelName+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布时间:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布单位:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布类型:</span>"+
										"<span class=\"info-content\">"+leixing+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">影响区域:</span>"+
										"<span class=\"info-content\">"+
											jsons.rows[i].areadesc+
										"</span>"+
									"</li>"+
								"</ul>"+
							"</div>"+
						"</div>"+
					"</li>";
					document.getElementById('monthWarningUl').innerHTML = li;
				}
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			},
			error: function (xhr) {
				alert('系统错误，请联系管理员！！');
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			}
		});
		//返回页面顶端
		scrollTo(0,0);
	}
}

//本年度预警下一页
function downYearPage(){
	var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
	$("body").append(loading);
	var currPage = document.getElementById ("yearCurrPage").innerHTML;
	var totalPages = document.getElementById ("yearTotalPages").innerHTML;
	if(currPage==totalPages){
		alert("已经在最后一页！");
		$(".loading").fadeOut();
	}else{
		var loading = '<div class="loading"><div class="pic"><i></i><i></i><i></i><i></i><i></i></div></div>'
		$("body").append(loading);
		//获取本年时间
		var systemDate = new Date();  
		// 获取当年    
		var year = systemDate.getFullYear(); 

		var startDate = year+"-01-01 00:00:00";
		var endDate = year+"-12-31 00:00:00";
		$.ajax({
			url:Global.common.ajaxPath+"/AlertInfo/checkAlertInfo.do",
			type : "post",
			datatype: "json",
			async: true,
			data:{
				sendtimestart : startDate,
				sendtimestop : endDate,
				page : parseInt(currPage)+1,
				rows : 5
			},
			success: function(jsons){
				//获取当前页码
				document.getElementById ("yearCurrPage").innerHTML = jsons.page;
				//获取总页数
				document.getElementById ("yearTotalPages").innerHTML = jsons.total;
				//事件类别名称数组
				var productNameArray = new Array();
				//翻页前删除原页面加载的数据
				document.getElementById('yearWarningUl').innerHTML = "";
				var li = "";
				for(var i in jsons.rows){
					//将事件类别编码转成事件类别名称
					if(jsons.rows[i].eventType!=undefined){
						$.ajax({
							async: false,
							data:{"productcode":jsons.rows[i].eventType},
							url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
							success: function(data){
								productNameArray[i] = data.productName;
							},
							error: function (xhr) { console.log('加载事件类别出错！'); }
						}); 
					}else{
						productNameArray[i] = "";
					}
					var levelName = "未知";
					if(jsons.rows[i].alamlevels.alamlevelName!=""){
						levelName = jsons.rows[i].alamlevels.alamlevelName.substring(0,4);
					}
					
					//获取预警信息发布类型
					var leixing = "";
					if(jsons.rows[i].alerts.status==="0"){
						leixing = "实际预警";
					}else if(jsons.rows[i].alerts.status=="1"){
						leixing = "测试预警";
					}
					
					var processName = "";
					if(jsons.rows[i].processStatuss!=undefined){
						processName = jsons.rows[i].processStatuss.statusName;
					}
					
					var imgFlag = "";
					var imgUrl = "";
					var title = jsons.rows[i].headline;
					for(var j=0; j<Global.monitor.yjxh.length; j++){
						if(typeof title == "string" && title.indexOf(Global.monitor.yjxh[j].name) >= 0 && title.indexOf(Global.monitor.yjxh[j].level) >= 0){
							imgFlag = Global.monitor.yjxh[j].flag;
							break;
						}
					}
					for(var j=0; j<Global.monitor.imgUrl.length; j++){
						if(imgFlag == Global.monitor.imgUrl[j].name){
							imgUrl = Global.monitor.imgUrl[j].value;
							break;
						}
					}
					if(imgUrl == ""){
						if(typeof title == "string" && title.indexOf("蓝色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_blue.png";
						}else if(typeof title == "string" && title.indexOf("黄色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_yellow.png";
						}else if(typeof title == "string" && title.indexOf("橙色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_orange.png";
						}else if(typeof title == "string" && title.indexOf("红色") >= 0){
							imgUrl = "resources/images/indexMap/adefault_red.png";
						}
					}
					
					li += "<li class=\"warning-list\">"+
						"<div class=\"warning-con\">"+
							"<div class=\"warning-time\">"+
								"<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"+
								"<span>"+jsons.rows[i].alerts.sendTime+"</span>"+
								"<span class=\"warning-effect\">["+processName+"]</span>"+
							"</div>"+
							"<div class=\"warning-text-con\">"+
								"<img src=\"../"+imgUrl+"\" alt=\"\">"+
								"<div class=\"warning-text\">"+
									"<strong>["+jsons.rows[i].headline+"]</strong>"+
									jsons.rows[i].description+
								"</div>";
								if(processName=="预警草稿"||processName=="审核驳回"||processName=="签发驳回"||processName=="应急办签发驳回"){
									li += "<div class=\"details\" onclick=\"CheckLuru("+jsons.rows[i].alertinfoid+")\">"+
										"编辑预警"+
									"</div>";
								}else{
									li += "<div class=\"details\" onclick=\"CheckProcess("+jsons.rows[i].alertinfoid+")\">"+
										"查看详情"+
									"</div>";
								}
							li += "</div>"+
							"<div class=\"warning-infos\">"+
								"<ul>"+
									"<li>"+
										"<span class=\"info-text\">事件类别:</span>"+
										"<span class=\"info-content\">"+productNameArray[i]+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">预警级别:</span>"+
										"<span class=\"info-content\">"+levelName+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布时间:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sendTime+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布单位:</span>"+
										"<span class=\"info-content\">"+jsons.rows[i].alerts.sneder+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">发布类型:</span>"+
										"<span class=\"info-content\">"+leixing+"</span>"+
									"</li>"+
									"<li>"+
										"<span class=\"info-text\">影响区域:</span>"+
										"<span class=\"info-content\">"+
											jsons.rows[i].areadesc+
										"</span>"+
									"</li>"+
								"</ul>"+
							"</div>"+
						"</div>"+
					"</li>";
					document.getElementById('yearWarningUl').innerHTML = li;
				}
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			},
			error: function (xhr) {
				alert('系统错误，请联系管理员！！');
				if ($("#profilea").ready){
					$(".loading").fadeOut();
				};
			}
		});
		//返回页面顶端
		scrollTo(0,0);
	}
}

//单击详情的操作 
function CheckProcess(id) {   
	var alertinfoid= id;
    var authorityDiv=$("#authorityDiv");
	
    authorityDiv.dialog({
        title:"预警信息详情",
    	height:590,
        width:950,
        resizable:false,
        modal:true,  //这里就是控制弹出为模态
        buttons:{
            "关闭":function(){$(this).dialog("close");
            	$("#eventTypequery").empty();
            	$("#headlinequery").empty();
            	$("#msgTypequery").empty();
            	$("#snederquery").empty();
	        	$("#sendTimequery").empty();
		        $("#statusquery").empty();
	    		$("#snederquery").empty();
		        $("#areadescquery").empty();
		        $("#strategyquery").empty();
		        $("#descriptionquery").empty();
		        $("#geocodequery").empty();
            	$("#resourcesizequery").empty();
            	$("#resourcedescquery").empty();
            	$("#resourcetypequery").empty();
            	$("#resourcedescqueryxml").empty();
		       	$("#resourcetypequeryxml").empty();
		       	$("#messagesquery").empty();
            },
            "打印":function(){
            //alert(alertinfoid);
            	$.ajax({ 
					//type: "post", 
					async: false,
					url: Global.common.ajaxPath+"/AlertInfo/checkAlmProcessLogOne.do",
					data:{alertinfoid:alertinfoid}, //data:{id:1}, 
					dataType : "json", // 指定返回类型 
					success: function(data) {
						//alert(data.almprocessstatus.statusName);
						if(data.almprocessstatus.statusName=="预警完成"){
							window.location.href = Global.common.ajaxPath+"/AlertInfo/checkAlertInfoPrintOne.do?alertinfoid="+alertinfoid;						
						}else{
							alert("预警信息处于"+data.almprocessstatus.statusName+"状态");
						}
					}, 
					error : function() { 
						console.log("加载预警流程失败！");
					} 
			   	});
				
            }
        }
    });
    
   
	$.ajax({ 
    	type: "post", 
  		url: Global.common.ajaxPath+"/AlertInfo/findAlertinfo.do",
  		data:{"alertinfoid":alertinfoid}, //data:{id:1}, 
  		dataType : "json", // 指定返回类型 
  		success: function(data) { 		    
	        var everythingtype = data.headline;
	        var alamlevel=data.alamlevels.alamlevelName;
	        //alert(everythingtype +"----"+alamlevel+"----"+(everythingtype.length-alamlevel.length-1));
	        var eventtypequery =everythingtype.substring(0,everythingtype.length-alamlevel.length);
	        //alert(eventtypequery);
	        //$("#eventTypequery").text(eventtypequery);
	        
	        $("#headlinequery").text(everythingtype);
	        
	        $("#alamlevelNamequery").text(data.alamlevels.alamlevelName);
	        
	        if(data.alerts.msgType==="0"){
		        $("#msgTypequery").text("首发预警");
	        }else if(data.alerts.msgType=="1"){
		        $("#msgTypequery").text("更新预警");
	        }else if(data.alerts.msgType=="2"){
		        $("#msgTypequery").text("解除预警");
	        }
	        $("#snederquery").text(data.alerts.sneder);
	        $("#sendTimequery").text(data.alerts.sendTime);
	        if(data.alerts.status==="0"){
		        $("#statusquery").text("实际预警");
	        }else if(data.alerts.status=="1"){
		        $("#statusquery").text("测试预警");
	        }
	        $("#snederquery").text(data.alerts.sneder);
	        $("#areadescquery").text(data.areadesc);
	        $("#descriptionquery").text(data.description);
	        $("#geocodequery").text(data.areas.areaname);
	       	if(data.audiences.methodName!=null){
	       	
		       	var methodNamequery = data.audiences.methodName;
		       	var methodName=methodNamequery.split(",");
		       	var globlemethod="";
		       	for(var i=0; i<methodName.length; i++){
		       		globlemethod +="<div class='checkbox'>" 
	                     + methodName[i]+
	                    "</div>";
		       	}
		       	//alert(globlemethod);
		        var globlespan = window.document.getElementById("methodNamequery");
		        globlespan.innerHTML=globlemethod;
	       	}
	       	
	       	var severity= data.severity;
	       	//alert(severity);
	       	var eventtype =data.eventType;
	       	//alert(eventtype);
	       	if(severity!=""&&eventtype!=""){
		       	params={
		       		"alarmLevel":severity,
		       		"productcode":eventtype
		       	};
		       	$.ajax({
					async: false,
					url: Global.common.ajaxPath+"/Strategy/selectStrategy3.do",
				 	data : params,
			  		success: function(data){
						if (data != null && data != "") {
							var obj = eval("("+data+")");
				  			$("#strategyquery").text(obj[0].value);
				  			document.getElementById("strategyId").value = obj[0].id;
			  			}else{
				  			$("#strategyquery").text("默认发布策略");
							document.getElementById("strategyId").value = "1";
			  			}
			  		}, 
			  		error : function() { 
			  		   console.log("请求失败！"); 
			  	    } 
			    }); 
		    }
		    if(eventtype!=""){
			    $.ajax({
					async: false,
					data:{"productcode":eventtype},
					url: Global.common.ajaxPath+"/Disaster/getDisaster.do",
					success: function(data){
					//alert(data);
						$("#eventTypequery").text(data.productName);
					},
					error: function (xhr) { console.log('加载事件类别出错！'); }
				}); 
		    }
		    
		    var resourcetypearr;
		    if(data.resourcedesc!=null) {
			   $("#resourcedescquery").text(data.resourcedesc); 
			   resourcetypearr = data.resourcedesc.split(".");
			   if(resourcetypearr[1]!=null&&resourcetypearr[1]!=""){
				   $("#resourcetypequery").text("."+resourcetypearr[1]); 
				}
		    }
		    
		    if(data.resourcesize!=null){
			   $("#resourcesizequery").text(data.resourcesize); 
		    }
		    //alert(data.resourcesize); 
		    //var obj = eval("("+data+")"); 
		    var alertsidentiferxml = data.identifier;
		    var alertssenderxml= data.alerts.sneder;
		    var alertssendercodexml=data.alerts.snadercode;
		    //var phonexml=
		    var sendTimexml=data.alerts.sendTime;
		    //alert(sendTimexml);

	       	 
	       	var identifiername=data.identifier;
	       	//alert(identifiername);
	       	$.ajax({ 
			//type: "post", 
				async: false,
			    url: Global.common.ajaxPath+"/AlertInfo/readxml.do",
				data:{identifiername:identifiername}, //data:{id:1}, 
				dataType : "text", // 指定返回类型 
				success: function(data) {
					//alert(data);
					if(data){
						var messagequeryxml = window.document.getElementById("messagesquery");
		       	 		messagequeryxml.innerHTML="<xmp>"+data+"</xmp>";
		       	 		$("#resourcedescqueryxml").text(identifiername+".xml");
		       	 		$("#resourcetypequeryxml").text(".xml");
					}else{
						//alert("没有找到文件");
						var messagequeryxml = window.document.getElementById("messagesquery");
		       	 		messagequeryxml.innerHTML="没有xml文件";
					}
					
				}, 
				error : function() { 
				 //alert("请求xml失败！");
				 	var messagequeryxml = window.document.getElementById("messagesquery");
		       	 	messagequeryxml.innerHTML="没有xml文件"; 
				} 
		   });
		   
	       $.ajax({ 
				//type: "post", 
				async: false,
			    url: Global.common.ajaxPath+"/AlertInfo/checkAlmProcessLog.do",
				data:{alertinfoid:alertinfoid}, //data:{id:1}, 
				dataType : "json", // 指定返回类型 
				success: function(data) {
					var alertinfolog ="";
					$.each(data,function(index,value){
					    //alertinfolog += "<div><span>预警进程:"+value.entrytime+value.almprocessstatus.statusName+ "</span>&nbsp;&nbsp;"+
					    // "<span>操作人:"+value.handleUser+ "</span></div><hr/>";
						//alert(value.handleUser);
						alertinfolog += "<li>"+
		                "<span class='date'>"+value.entrytime+"</span>"+
		                "<span class='week'>"+value.handleUser+"</span>"+
		                "<span class='text' style='text-align: center;'>"+value.almprocessstatus.statusName+"</span></li>";
					});
					$("#J_listtext2").html(alertinfolog);
					$("#J_listtext2 li:first").addClass("latest");
				}, 
				error : function() { 
				 	console.log("加载预警流程失败！");
				} 
		   });
	       	 
  		}, 
  		error : function() { 
  		   console.log("请求失败！"); 
  	    } 
    });
    //关闭dialog 
    authorityDiv.dialog("open");
    
}

//草稿编辑
function CheckLuru(id){
	window.location.href = Global.common.ajaxPath+"/html/info-issue.html?alertinfoid="+id;
}
